#ifndef __BMI088_TEXT_H__
#define __BMI088_TEXT_H__

#include "stdint.h"
#include "stdbool.h"
#include "stdlib.h"
#include "string.h"
#include "math.h"
#include "bmi088_reg.h"


#define BMI088_WRITE_ACCEL_REG_NUM 6
#define BMI088_WRITE_GYRO_REG_NUM 6

#define BMI088_ACCEL_XOUT_L 0x12
#define BMI088_TEMP_M 0x22
#define BMI088_GYRO_CHIP_ID 0x00
#define BMI088_GYRO_CHIP_ID_VALUE 0x0F

#define BMI088_TEMP_FACTOR 0.125f
#define BMI088_TEMP_OFFSET 23.0f

#define BMI088_ACCEL_6G_SEN 0.00179443359375f
#define BMI088_GYRO_2000_SEN 0.00106526443603169529841533860381f

#define BMI088_ACC_SOFTRESET 0x7E   /*!< Software Reset Register */
#define BMI088_ACC_SOFTRESET_VALUE 0xB6  /*!< The value written by the software reset register */

#define BMI088_LONG_DELAY_TIME 80

#define BMI088_LONG_DELAY_TIME 80
#define BMI088_COM_WAIT_SENSOR_TIME 150
/**
 * @brief typedef structure that contains the information for the received data.
 */
typedef struct
{
	int16_t Accel_X;   /*!< received x-axis angular acceleration data */
	int16_t Accel_Y;   /*!< received y-axis angular acceleration data */
	int16_t Accel_Z;   /*!< received z-axis angular acceleration data */

	int16_t Gyro_X;    /*!< received x-axis angular velocity data */
	int16_t Gyro_Y;    /*!< received y-axis angular velocity data */
	int16_t Gyro_Z;    /*!< received z-axis angular velocity data */

	int16_t Temperature; /*!< received temperature data */

}MPU_Info_Typedef;

/* Exported types ------------------------------------------------------------*/
/**
 * @brief typedef enum that contains the status for the BMI088.
 */
typedef enum
{
    BMI088_NO_ERROR                     = 0x00,
    BMI088_ACC_PWR_CTRL_ERROR           = 0x01,
    BMI088_ACC_PWR_CONF_ERROR           = 0x02,
    BMI088_ACC_CONF_ERROR               = 0x03,
    BMI088_ACC_SELF_TEST_ERROR          = 0x04,
    BMI088_ACC_RANGE_ERROR              = 0x05,
    BMI088_INT1_IO_CTRL_ERROR           = 0x06,
    BMI088_INT_MAP_DATA_ERROR           = 0x07,
    BMI088_GYRO_RANGE_ERROR             = 0x08,
    BMI088_GYRO_BANDWIDTH_ERROR         = 0x09,
    BMI088_GYRO_LPM1_ERROR              = 0x0A,
    BMI088_GYRO_CTRL_ERROR              = 0x0B,
    BMI088_GYRO_INT3_INT4_IO_CONF_ERROR = 0x0C,
    BMI088_GYRO_INT3_INT4_IO_MAP_ERROR  = 0x0D,

    BMI088_SELF_TEST_ACCEL_ERROR        = 0x80,
    BMI088_SELF_TEST_GYRO_ERROR         = 0x40,
    BMI088_NO_SENSOR                    = 0xFF,
}BMI088_Status_e;

/**
 * @brief typedef structure that contains the information for the BMI088.
 */
typedef struct
{
    bool Offsets_Init;    /*!< Initializes the offset flag */

    float Accel[3];       /*!< converted accelerator data */
    float Gyro[3];        /*!< converted gyro data */
    float Temperature;    /*!< converted temperature data */

    MPU_Info_Typedef MPU_Info;/*!< bmi088 received data */

    float Offsets_Gyro_X;   /*!< offsets of x-axis angular velocity */
    float Offsets_Gyro_Y;   /*!< offsets of y-axis angular velocity */
    float Offsets_Gyro_Z;   /*!< offsets of z-axis angular velocity */
	
}BMI088_Info_Typedef;


extern BMI088_Info_Typedef BMI088_Info;
void BMI088_Init(void);
	
#endif

